/*
 * 文 件 名:  ActionMapping.java
 * 版    权:  Chrhc Technologies Co., Ltd. Copyright 2015-2099,  All rights reserved
 * 描    述:  <描述>
 * 修 改 人: 姓名 xxx
 * 修改时间:  2016年4月19日
 */
package com.struts;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

/**
 * <一句话功能简述> <功能详细描述>
 * 
 * @author 姓名 xxx
 * @version [1.0, 2016年4月19日]
 */
public class ActionMapping
{
    
    private String name;
    
    private String path;
    
    private String type;
    
    private String formBeanType;

    private Map<String, ActionForward> actionForwards = new HashMap();

    /**
     * 获取 name
     * 
     * @return 返回 name
     */
    public String getName()
    {
        return name;
    }
    
    /**
     * 设置 name
     * 
     * @param 对name进行赋值
     */
    public void setName(String name)
    {
        this.name = name;
    }
    
    /**
     * 获取 path
     * 
     * @return 返回 path
     */
    public String getPath()
    {
        return path;
    }
    
    /**
     * 设置 path
     * 
     * @param 对path进行赋值
     */
    public void setPath(String path)
    {
        this.path = path;
    }
    
    /**
     * 获取 type
     * 
     * @return 返回 type
     */
    public String getType()
    {
        return type;
    }
    
    /**
     * 设置 type
     * 
     * @param 对type进行赋值
     */
    public void setType(String type)
    {
        this.type = type;
    }
    
    /**
     * 获取 formBeanType
     * 
     * @return 返回 formBeanType
     */
    public String getFormBeanType()
    {
        return formBeanType;
    }
    
    /**
     * 设置 formBeanType
     * 
     * @param 对formBeanType进行赋值
     */
    public void setFormBeanType(String formBeanType)
    {
        this.formBeanType = formBeanType;
    }
    
    /**
     * 获取 actionForwards
     * 
     * @return 返回 actionForwards
     */
    public Map<String, ActionForward> getActionForwards()
    {
        return actionForwards;
    }
    
    /**
     * 设置 actionForwards
     * 
     * @param 对actionForwards进行赋值
     */
    public void setActionForwards(Map<String, ActionForward> actionForwards)
    {
        this.actionForwards = actionForwards;
    }
    

    
    public ActionForward findForward(String forward)
    {
        return actionForwards.get(forward);
    }
    
    public Action newInstanceAction()
    {
        try
        {
            Class clazz = Class.forName(type);
            try
            {
                Action action = (Action)clazz.newInstance();
                return action;
            }
            catch (InstantiationException  e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }catch (IllegalAccessException e){
                e.printStackTrace();
            }
        }
        catch (ClassNotFoundException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }
    
    public ActionForm genFormBeanRequest(HttpServletRequest request)
    {
        return FormBean.genFormBeanRequest(request, formBeanType);
    }
}
